home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue25 / tiptrix / listing3.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-18  |  856 b   |  36 lines

  1. unit StrFake;
  2.  
  3. {small unit to allow to set the capacity in a TStringList object}
  4.  
  5. interface uses Classes;
  6.  
  7. {- exposed routine : set capacity in a string list -}
  8. procedure SetStringListCapacity(SL: TStringList; Size: integer);
  9.  
  10. implementation
  11.  
  12. type TStringListFake = class(TStrings)
  13.   public
  14.     FList: PStringItemList;
  15.     FCount: Integer;
  16.     FCapacity: Integer;
  17.     procedure SetCapacity(NewCapacity: Integer);
  18. end;
  19.  
  20. procedure TStringListFake.SetCapacity(NewCapacity: Integer);
  21. begin
  22.   ReallocMem(FList, NewCapacity * SizeOf(TStringItem));
  23.   FCapacity := NewCapacity;
  24. end;
  25.  
  26. procedure SetStringListCapacity(SL: TStringList; Size: integer);
  27. {$IFNDEF VER90}
  28.  !! 'check class "TStringListFake" with other version than Delphi 2'
  29. {$ENDIF}
  30. var XL : TStringListFake absolute SL;
  31. begin
  32.   XL.SetCapacity(Size);
  33. end;
  34.  
  35. end.
  36.